/**Created on December 13, 2007, 8:51 PM
 */
//Must import this to use the input & message boxes (See Text page 22)
import javax.swing.JOptionPane;
import java.util.InputMismatchException;


public class Main  {
    
  public static void main(String[] args) {
     /*Created a variableString (totalGradesString) to assign the input from 
      *from the user.  These boxes only return string inputs(See Text page 45,
      *section 2.11), so they must be converted to numbers, 
      *before numeric manipulation.*/
    
      String totalGradesString = JOptionPane.showInputDialog(null, "Number" + 
             " of grades to be averaged:", "TOTAL GRADES Maria?", JOptionPane.QUESTION_MESSAGE);
        
      
     /*This is to convert the user input to an integer(See Text page 46,
      *section 2.11.1)*/
        int totalGrades = Integer.parseInt(totalGradesString);
 
     /*I'm declaring a constant (See Text page 33), the total number
      * of grades to be averaged, which will be entered by the user*/
    final int TOTAL_NUMBERS = totalGrades;
    
    /*I'm creating an array using new dataType[arraySize](See Text page 170,
     *section 6.2.2)and the size of the array is the input from the user*/
    int[] numbers = new int[TOTAL_NUMBERS];
   
    /*I'm using a for loop to read all the numbers  entered 
     *by the user when I ask for the grade scores(See C++ Text on For Loops)*/
       
    for (int i = 0; i < numbers.length; i++) {
      String numString = JOptionPane.showInputDialog(null,
      "Enter grade score:", "From 0 to 100 Nena Latina!", JOptionPane.QUESTION_MESSAGE);
    
          
            
//Insert exception handler right here ****************************
      
     

                   
      /* Convert strings into integers!!!
       *Remember that the input/dialog boxes only return strings
       *(Text page 46, section 2.11.1)*/
      numbers[i] = Integer.parseInt(numString);
    
    
        
    /* I'm declaring a variable int to store the total, after all
     *grades has been added; I'm declaring a variable int to store
     *the average of (total / number of grades);  I'm using a For Loop
     *to add all the grades entered into the array;  I'm taking 
     *(total / totalGrades) and assigning it to average*/
    int total = 0;
    int average = 0;
    int total= += numbers[i];
    int average = (total / totalGrades);
    
    
    }
    //I'm using a Message box to display anything I want!!!
    String output = "The " + totalGrades + " grades average is " + average;
    JOptionPane.showMessageDialog(null, output, "GRADE AVERAGE", JOptionPane.PLAIN_MESSAGE);
  }
  
}
 
    


 
 